//引入二次封装axios
import request from '@/utils/request';

//api相关接口
enum API {
	//获取已有品牌的数据
	getTrademarkList = '/admin/product/baseTrademark/',
	//添加品牌
	addTrademark = '/admin/product/baseTrademark/save',
	//修改品牌
	UpdateTrademark = '/admin/product/baseTrademark/update',
	//删除品牌
	deleteTrademark = '/admin/product/baseTrademark/remove/',
	///admin/product/baseTrademark/remove/{id}
}

//分别暴漏接口

//获取已有品牌的数据
export const reqTrademarkList = (page: number, limit: number) =>
	request.get(API.getTrademarkList + `${page}/${limit}`);
//添加和修改品牌，有没有id
export const reqAddOrUpdateTrademark = (data: any) => {
	if (data.id) {
		//有id，修改品牌
		request.put(API.UpdateTrademark, data);
	} else {
		//没有id，添加品牌
		request.post(API.addTrademark, data);
	}
};

//删除品牌
export const reqRemoveTrademark = (id: number) =>
	request.delete(API.deleteTrademark + id);
